function y=xidfnew(xivals,alphbar,acost,bcost,scriptB)
%
% Compute PDF of fixed cost using the BEta dist. as the primitive dist.
%
% Input:
% 1. xivals: the specific cost
% 2. alphbar: the proportion of firms receiving zero cost
% 3. acost: a parameter for the Beta/Dotsey dist.
% 4. bcost: a parameter for the Beta/Dotsey dist.
% 5. scriptB: the largest fixed cost
%


xivals=min(xivals,scriptB);
xivals=max(xivals,0);


%% BETA distribution

% % converted support for Beta dist.
% z = xivals/scriptB;
% 
% % the BETA function given a,b
% betafunc = beta(acost,bcost);
% 
% % PDF of beta dist.
% pdf = (1/betafunc).*(z.^(acost-1)).*((1-z).^(bcost-1));
% 
% % final PDF
% y = ((1-alphbar)*(1/scriptB)).*pdf;

%%


%% DOTSEY distribution

z=xivals/scriptB;

minp=min([acost bcost]);
maxp=max([acost bcost]);

if (minp<=-pi/2)||(bcost>=pi/2)
    disp('inadmissable parameter values for dotsey distribution')
    disp('in call to xcidf.m')
end

K1=1/(tan(bcost)-tan(acost));
K2=-tan(acost)*K1;

x=z*bcost+(1-z)*acost;
y=K1*(bcost-acost)*sec(x).^2;

% modify to reflect distribution of xi rather than z
y=y/scriptB;

% modify underlying distribution to produce adjusted distribution
y=(1-alphbar)*y;


%%

end
